import numpy as np
from sklearn.preprocessing import Imputer

data = [[1, 2],
        [np.nan, 3],
        [7, 6]]


# 定义缺失值
imputer = Imputer(missing_values='NaN',strategy='mean', axis=0)
result = imputer.fit_transform(data)
print(result)
# [[ 1.  2.]
#  [ 4.  3.]
 # [ 7.  6.]]